package me.ywd.config.client.controller;

import me.ywd.config.client.cache.StatefulBean;
import me.ywd.config.client.config.ConfigProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author Ye_Wenda
 * @Date 8/8/2017
 */
@RestController
public class ConfigClientDemoController {
    @Value("${foul}")
    private String foul;
    @Value("${test.value}")
    private String testValue;

    @Autowired
    private ConfigProperties configProperties;

    @Autowired
    private StatefulBean statefulBean;

    @GetMapping
    public String get() {
        return foul + " " + testValue
                + "<br/>\n" + configProperties.getSimpleProp()
                + "<br/>\n" + configProperties.getArrayProps()[1]
                + "<br/>\n" + configProperties.getListProp1().get(0).get("name")
                + "<br/>\n" + configProperties.getListProp2().get(0)
                + "<br/>\n" + configProperties.getMapProps().get("key1")
                + "<br/>\n" + statefulBean.getAbc();
    }
}
